<template>
<div class="">
<div class="loader-base" v-if="showLoad"><div class="loader-wrap"></div></div>
  <scroller lock-x height="-52" @on-scroll-bottom="onScrollBottom" ref="scrollerBottom" :scroll-bottom-offst="100" v-if="todolist.length>0">
    <div>
      <div class="msg-wrap">
        <div class="msg-list displayflex" @click="goD(item.Guid)" v-for="item in todolist">
          <div class="left"><i class="iconfont icon-notice"></i></div>
          <dl class="ctx flex1">
            <dt class="ft17">{{item.Title}}</dt>
            <dd class="ft14">{{item.Content}}</dd>
          </dl>
          <i class="iconfont icon-right rit"></i>
        </div>
      </div>
      <p class="txt-bottom" v-if="totalLength == todolist.length"><em class="txt">我是有底线的</em></p>
    </div>
  </scroller>
  <div class="noDate_page" v-if="todolist.length<=0">
    <div class="noDate_icon"><i class="iconfont icon-null"></i></div>
    未找到相关数据
  </div>
  <foot-box :status="3"></foot-box>
</div>
</template>

<script>
import footBox from "@/components/share/footerbox.vue";
export default {
  data() {
    return {
      todolist: [],
      count:0,
      pageindex:1,
      totalLength:0,
      showLoad:false,
    };
  },
  components: {
    footBox
  },
  computed: {
    userinfo() {
      if (localStorage.UserInfo) {
        return JSON.parse(localStorage.UserInfo);
      }
    }
  },
  created() {
    this.getData();
  },
  methods: {
    goD(guid) {
      this.$router.push({
        path: "/message/detail",
        query:{id:guid}
      });
    },
    onScrollBottom () {
      this.count++;
      if(this.count==1){
        this.getData();
        this.$nextTick(() => {
          this.$refs.scrollerBottom.reset();
        });
      };
    },
    getData() {
      this.showLoad = true;
      var self = this;
      var query = {
        ReceiverGuid:self.userinfo.StaffID,
        PageIndex:this.pageindex,
        PageSize:8
      };
      this.Ajax.post("SearchNotificationList", query).then(function(resp) {
        self.showLoad = false;
        if (resp.IsSuccess) {
          var result = resp.Datas;
          if(result.length > 0){
            self.todolist=self.todolist.concat(result);
            self.pageindex++;
            self.count = 0;
          };
          self.totalLength = resp.TotalRecords;
        }
      });
    }
  }
};
</script>

